package com.qfjy.controller;

import com.qfjy.commons.util.resulst.ResultCode;
import com.qfjy.commons.util.resulst.ResultJson;
import com.qfjy.entity.po.Demo;
import com.qfjy.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Classname DemoController
 * @Author guoweixin
 * @Description TODO
 * @Date 2021/10/10 10:41
 * @Created by Administrator
 */
@Controller
@RequestMapping("demo")
public class DemoController {

    @Autowired
    private DemoService demoService;

    @GetMapping("byId")
    @ResponseBody
    public ResultJson selectById(@RequestParam("id") int id){
        Demo demo=demoService.selectByPrimaryKey(id);
        if(demo==null){
            return  new ResultJson(null, ResultCode.NOT_DATA);
        }
        return new ResultJson(demo,ResultCode.SUCCESS);
    }
}
